package cmd

import (
	"chigo/internal"
	"chigo/pkg" //将chigo/pkg 起别名为chigo
	"fmt"

	"github.com/mattn/go-colorable"
)

func Main() {
	// Windows Support
	defer colorable.EnableColorsStdout(nil)() //启动颜色
	fmt.Println(VERSION, HELP_MESSAGE)
	help, fileArguments, files := parametersAndFlags() //解析参数和标志

	if help {
		printHelp()
		return
	}

	if fileArguments {
		data, error := internal.JoinFiles(files)

		if error != nil {
			fmt.Println(chigo.Colorize(error.Error()))
			return
		}

		fmt.Println(chigo.Colorize(data))
		return
	}

	internal.StartProcessFromStdin() //渲染输入到终端
}
